/*
 * @Description: 
 * @Author: 于子续
 * @Date: 2024-09-02 14:44:48
 * @LastEditors: 于子续
 * @LastEditTime: 2024-09-03 18:21:59
 */
package day06;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        while (true) {
            int year = yearcs();
            System.out.println("输入月份：");
            Scanner cs = new Scanner(System.in);

            if (isLeapYear(year)) {
                System.out.println(year + " 是闰年");
            } else {
                System.out.println(year + " 不是闰年");
            }

        }
    }

    public static boolean isLeapYear(int year) {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            return true;
        } else {
            return false;
        }
    }

    public static int yearcs() {
        int year = 6;
        System.out.println("请输入一个年份,输入0退出程序:");
        Scanner cs = new Scanner(System.in);
        year= cs.nextInt();
        while ((year >= 0 && year < 1900) || year > 2050) {
            year = cs.nextInt();
            if (year == 0) {
                System.exit(0);

            }
            System.out.println("输入的年份不合法,请重新输入！");
        }

        return year;

    }

}
